package com.ty.mapper;

import com.ty.entity.OrderItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author txy
 * @since 2024-03-02
 */
public interface OrderItemMapper extends BaseMapper<OrderItem> {
    @Select("select * from order_item where order_id =#{id}")
    @Results({
            //因为type_id字段拿去关联外表，想要赋值给bookinfo还要再映射一次
            @Result(property = "periodicalId", column = "periodical_id"),
            @Result(property = "periodical", column = "periodical_id",
                    one = @One(select = "com.ty.mapper.BookMapper.selectBooksById"))
    })
    OrderItem selectByOrderItemById(String id);
}
